package com.shyb.lingxian.Util;

import android.content.Context;
import android.view.Gravity;
import android.widget.Toast;

/**
 * Created by gs on 2018/3/23.
 */

public class ToastUtil {

    public static Toast mToast;
    /**
     * 立即连续弹吐司
     * @param mContext
     * @param msg
     */
    public static void showToast(final Context mContext, final String msg) {
        CommonUtils.runOnUIThread(new Runnable() {
            @Override
            public void run() {
                if (mToast == null) {
                    mToast = Toast.makeText(mContext, "", Toast.LENGTH_SHORT);
                }
                mToast.setGravity(Gravity.CENTER,0,0);
                mToast.setText(msg);
                mToast.show();

            }
        });
    }

    public static void showLongToast(final Context mContext, final String msg) {
        CommonUtils.runOnUIThread(new Runnable() {
            @Override
            public void run() {
                if (mToast == null) {
                    mToast = Toast.makeText(mContext, "", Toast.LENGTH_LONG);
                }
                mToast.setGravity(Gravity.CENTER,0,0);
                mToast.setText(msg);
                mToast.show();

            }
        });
    }
}
